package com.caigou.service.impl;

import com.caigou.bean.cms.entity.ChannelData;
import com.caigou.bean.empire.entity.EmpireSyncArticleData;
import com.caigou.component.EmpireDataSyncComponent;
import com.caigou.mapper.empire.EmpireDataSyncMapper;
import com.caigou.service.ChannelDataService;
import com.caigou.service.EmpireDataSyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service("empireDataSyncService")
public class EmpireDataSyncServiceImpl implements EmpireDataSyncService {

    @Resource
    private EmpireDataSyncMapper empireDataSyncMapper;
    @Resource
    private ChannelDataService channelDataService;

    @Override
    public List<EmpireSyncArticleData> loadEmpireSyncArticleDataByPlate(Long lastTime, Long syncTime, Integer limit) {
        return empireDataSyncMapper.loadEmpireSyncArticleDataByPlate1(lastTime,syncTime,limit);
    }

    @Override
    public List<EmpireSyncArticleData> loadEmpireSyncArticleDataByPlate2(Long lastTime, Long syncTime, Integer limit) {
        return empireDataSyncMapper.loadEmpireSyncArticleDataByPlate2(lastTime,syncTime,limit);
    }

    @Override
    public EmpireSyncArticleData loadEmpireSyncArticleDataById(Integer id) {
        return empireDataSyncMapper.loadEmpireSyncArticleDataById(id);
    }

    @Override
    public void saveRssData() {
        List<String> articleList = channelDataService.loadRssList();
        articleList.forEach(item -> {
            channelDataService.saveChannelData(-1,item,"-1",1,0,0,0,0);
        });
    }
}
